<button class="btn btn-info" type="button" onclick="backtoMain()">返回</button><br>
<table class="table" id="pomainDiv">
    <thead>
    <tr>
        <th>采购单编号</th>
        <th>入库日期</th>
        <th>产品编号</th>
        <th>产品名称</th>
        <th>产品数</th>
        <th>产品总金额</th>
    </tr>
    </thead>
    <tbody id="tableBody"></tbody>
</table>


<script id="inStoreItemReportTemplate" type="text/html">
    {{each data value index}}
    <tr>
        <td>{{value.orderCode}}</td>
        <td>{{value.stockTime}}</td>
        <td>{{value.productCode}}</td>
        <td>{{value.productList[0].name}}</td>
        <td>{{value.stockNum}}</td>
        <td>{{value.productTotal}}</td>
        <td><input type="button" value="查看采购单明细" onclick="topomain('{{value.orderCode}}')"></td>
    </tr>
    {{/each}}
</script>

<script>
    $(function () {
        Ajax.post(
            "/selectInStorePrice",
            {date:sessionStorage.getItem("inStoredate")},
            function (result) {
                for(var i=0;i<result.data.length;i++){
                    result.data[i]["productTotal"]=result.data[i].stockNum*result.data[i].productList[0].price
                }
                var div=document.getElementById("tableBody")
                var html=template('inStoreItemReportTemplate',{data:result.data})
                div.innerHTML=html
            }
        )
    })
    function backtoMain() {
        sessionStorage.setItem("backinStoredate",sessionStorage.getItem("inStoredate"))
        show("/report/inStoreReport.html")
    }
    function topomain(obj) {
        window.sessionStorage.setItem("poId",obj)
        show("/report/reportPomainSearch.html")
    }
</script>
